package xddq

import (
	"fmt"
	D "websocket_apn/define"
	"websocket_apn/log"
	"websocket_apn/proto"
)

//地图数据
var HolyLandAddMapData = map[int]D.HolyLandAddMapInfo{
	1001: {Level: 1, Name: "基地-上", Link: []int{2002, 2003}},
	1002: {Level: 1, Name: "基地-右上", Link: []int{2022, 2023}},
	1003: {Level: 1, Name: "基地-左下", Link: []int{2010, 2011}},
	1004: {Level: 1, Name: "基地-下左", Link: []int{2012, 2013}},
	1005: {Level: 1, Name: "基地-下", Link: []int{2014, 2015}},
	1006: {Level: 1, Name: "基地-上右", Link: []int{2001, 2024}},
	1007: {Level: 1, Name: "基地-左", Link: []int{2008, 2009}},
	1008: {Level: 1, Name: "基地-上左", Link: []int{2004, 2005}},
	1009: {Level: 1, Name: "基地-左上", Link: []int{2006, 2007}},
	1010: {Level: 1, Name: "基地-右", Link: []int{2020, 2021}},
	1011: {Level: 1, Name: "基地-右下", Link: []int{2018, 2019}},
	1012: {Level: 1, Name: "基地-下右", Link: []int{2016, 2017}},
	2001: {Level: 2, Name: "金华灵脉", Link: []int{1006, 2002, 2024, 4001}},
	2002: {Level: 2, Name: "桃山灵脉", Link: []int{1001, 2001, 2003, 4001}},
	2003: {Level: 2, Name: "天目灵脉", Link: []int{1001, 2002, 2004, 4001}},
	2004: {Level: 2, Name: "紫盖灵脉", Link: []int{1008, 2003, 2005, 4001}},
	2005: {Level: 2, Name: "良常灵脉", Link: []int{1008, 2004, 2006, 3004}},
	2006: {Level: 2, Name: "若水灵脉", Link: []int{1009, 2005, 2007, 3004}},
	2007: {Level: 2, Name: "青田灵脉", Link: []int{1009, 2006, 2008, 4003}},
	2008: {Level: 2, Name: "金庭灵脉", Link: []int{1007, 2007, 2009, 4003}},
	2009: {Level: 2, Name: "大有灵脉", Link: []int{1007, 2008, 2010, 4003}},
	2010: {Level: 2, Name: "洞阳灵脉", Link: []int{1003, 2009, 2011, 4003}},
	2011: {Level: 2, Name: "寻罗灵脉", Link: []int{1003, 2010, 2012, 3003}},
	2012: {Level: 2, Name: "白石灵脉", Link: []int{1004, 2011, 2013, 3003}},
	2013: {Level: 2, Name: "都乔灵脉", Link: []int{1004, 2012, 2014, 4002}},
	2014: {Level: 2, Name: "紫竹灵脉", Link: []int{1005, 2013, 2015, 4002}},
	2015: {Level: 2, Name: "华盖灵脉", Link: []int{1005, 2014, 2016, 4002}},
	2016: {Level: 2, Name: "华清灵脉", Link: []int{1012, 2015, 2017, 4002}},
	2017: {Level: 2, Name: "玉循灵脉", Link: []int{1012, 2016, 2018, 3002}},
	2018: {Level: 2, Name: "常水灵脉", Link: []int{1011, 2017, 2019, 3002}},
	2019: {Level: 2, Name: "清与灵脉", Link: []int{1011, 2018, 2020, 4004}},
	2020: {Level: 2, Name: "玉留灵脉", Link: []int{1010, 2019, 2021, 4004}},
	2021: {Level: 2, Name: "清远灵脉", Link: []int{1010, 2020, 2022, 4004}},
	2022: {Level: 2, Name: "商谷灵脉", Link: []int{1002, 2021, 2023, 4004}},
	2023: {Level: 2, Name: "抱福灵脉", Link: []int{1002, 2022, 2024, 3001}},
	2024: {Level: 2, Name: "漳龙灵脉", Link: []int{1006, 2001, 2023, 3001}},
	2025: {Level: 2, Name: "青月灵脉", Link: []int{3001, 4004, 5001}},
	2026: {Level: 2, Name: "玉虚灵脉", Link: []int{3004, 4001, 5001}},
	2027: {Level: 2, Name: "苍山灵脉", Link: []int{3003, 4003, 5001}},
	2028: {Level: 2, Name: "冰玄灵脉", Link: []int{3002, 4002, 5001}},
	3001: {Level: 3, Name: "定阳灵脉", Link: []int{2023, 2024, 2025}},
	3002: {Level: 3, Name: "无妄灵脉", Link: []int{2017, 2018, 2028}},
	3003: {Level: 3, Name: "长留灵脉", Link: []int{2011, 2012, 2027}},
	3004: {Level: 3, Name: "三危灵脉", Link: []int{2005, 2006, 2026}},
	4001: {Level: 4, Name: "圣源灵脉", Link: []int{2001, 2002, 2003, 2004, 2026}},
	4002: {Level: 4, Name: "南洲灵脉", Link: []int{2013, 2014, 2015, 2016, 2028}},
	4003: {Level: 4, Name: "西洲灵脉", Link: []int{2007, 2008, 2009, 2010, 2027}},
	4004: {Level: 4, Name: "东洲灵脉", Link: []int{2019, 2020, 2021, 2022, 2025}},
	5001: {Level: 5, Name: "九仙灵脉", Link: []int{2025, 2026, 2027, 2028}},
	6001: {Level: 6, Name: "修罗城", Link: []int{}},
}

//九幽争霸-处理灵气状态
func (xd *XdDriver) CheckHolyLandSpiInfoData(info D.HolyLandSpiInfo) {
	xd.UserData.HolyLandInfo.Spi = info
	if info.Save > 0 && info.SpiLimit-info.Spi > 0 {
		addSpi := info.SpiLimit - info.Spi
		if addSpi > info.Save {
			addSpi = info.Save
		}
		log.Infof("九幽争霸-开始恢复%d灵力", addSpi)
		xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_GOD_ISLAND_GAME_USE_SPIRITUALBALL, fmt.Sprintf("08 %s 10 %s",
			xd.UserData.Activity[D.Activity_GOD_ISLAND_GAME_PLANT].ID, proto.HexToHexStr(proto.IntDataToBytes(addSpi)))))
	}
}

//九幽争霸-处理地图信息
func (xd *XdDriver) CheckHolyLandMapInfoData(info D.HolyLandMapInfo) {
	xd.UserData.HolyLandInfo.MapD = HolyLandAddMapData
	//for idx, _ := range info.Add {
	//	if info.Add[idx].PlaceId < 1500 {
	//		//是否是大本营
	//		if info.Add[idx].YmID == xd.UserData.YaoMengID {
	//			info.Add[idx].IsOccupy = true
	//			xd.UserData.HolyLandInfo.MapD[info.Add[idx].PlaceId].IsStart = true
	//			xd.UserData.HolyLandInfo.SelfPlaceID = info.Add[idx].PlaceId
	//		} else {
	//			xd.UserData.HolyLandInfo.MapD[info.Add[idx].PlaceId].IsStart = false
	//		}
	//	} else {
	//		if info.Add[idx].YmID == xd.UserData.YaoMengID {
	//			info.Add[idx].IsOccupy = true
	//			xd.UserData.HolyLandInfo.MapD[info.Add[idx].PlaceId].IsOS = true
	//		} else if len(info.Add[idx].YmID) > 0 {
	//			xd.UserData.HolyLandInfo.MapD[info.Add[idx].PlaceId].IsOE = true
	//		} else {
	//			xd.UserData.HolyLandInfo.MapD[info.Add[idx].PlaceId].IsOS = false
	//			xd.UserData.HolyLandInfo.MapD[info.Add[idx].PlaceId].IsOE = false
	//		}
	//	}
	//}
	xd.UserData.HolyLandInfo.Map = info
	//if info.Save > 0 && info.SpiLimit-info.Spi > 0 {
	//	addSpi := info.SpiLimit - info.Spi
	//	if addSpi > info.Save {
	//		addSpi = info.Save
	//	}
	//	log.Infof("九幽争霸-开始恢复%d灵力", addSpi)
	//	xd.Send(proto.Get_Cmd_Data(xd.userInfo.PlayerId, proto.S_GOD_ISLAND_GAME_USE_SPIRITUALBALL, fmt.Sprintf("08 %s 10 %s",
	//		xd.UserData.Activity[D.Activity_GOD_ISLAND_GAME_PLANT].ID, proto.HexToHexStr(proto.IntDataToBytes(addSpi)))))
	//}
}

/*
使用蓬莱仙果
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  193]:   ↑↑↑↑↑ S_GOD_ISLAND_GAME_USE_FRUIT - len:25
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  200]:   PayloadBytes: 71 AB 00 00 00 19 00 03 27 F5 00 00 02D4 07 01 81 E2 08 E2 B7 E5 04 10 09
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  195]:   ↓↓↓↓↓ game cmd[6837]-unkown - len:45
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  200]:   PayloadBytes: 71 AB 00 00 00 2D 00 00 1A B5 00 00 02D4 07 01 81 E2 08 00 12 08 31 30 35 30 33 39 3D 39 1A 05 39 36 39 38 35 22 06 34 39 33 33 31 30
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  203]:   	>>> 1 - code 08[8] len:0-_
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  203]:   	>>> 2 - code 12[18] len:8-31 30 35 30 33 39 3D 39_
105039=9
[DEBUG] [2024/09/25 20:28:16] [PRJ/websocket_apn/main_test.go]:[  203]:   	>>> 3 - code 1A[26] len:5-39 36 39 38 35_
96985
*/
